package org.example.everyday;

/**
 * https://leetcode-cn.com/problems/count-of-matches-in-tournament/
 */
public class NumberOfMatches {

    public static void main(String[] args) {
        int result = solution1(3);
        System.out.println(result);
    }

    public static int solution1(int n){
        int ans = 0;
        while (n>1){
            if(n%2 == 0){
                ans = ans + n/2;
                n = n/2;
            }else{
                ans=ans+ (n - 1) / 2;
                n = (n-1)/2 + 1;
            }
        }

        return ans;
    }
}
